# -*-coding:utf-8-*-

from tests.apis.http import *
from tests.apis.base import BaseAPI


class Roles(BaseAPI):
    def __init__(self, *args, **kwargs):
        super(Roles, self).__init__(*args, **kwargs)

    def create_role(self, *args, **kwargs):
        response = http_post('platform/api/roles', kwargs, self.query)
        return self.assert_response_success_data(response)

    def delete_role(self, *args, **kwargs):
        role_id = kwargs['role_id']
        response = http_delete('platform/api/roles/%s' % role_id, query=self.query)
        return self.assert_response_success_data(response)

    def update_role(self, *args, **kwargs):
        role_id = kwargs['role_id']
        response = http_put('platform/api/roles/%s' % role_id, kwargs, query=self.query)
        return self.assert_response_success_data(response)

    # def get_role_list(self, *args, **kwargs):
    #     response = http_get('platform/api/roles', self.query)
    #     return self.assert_response_success_data(response)

    def get_subordinate_role_list(self, *args, **kwargs):
        role_id = kwargs['role_id']
        response = http_get('platform/api/roles/%s/subordinates' % role_id, self.query)
        return self.assert_response_success_data(response)

    def get_sibling_role_list(self, *args, **kwargs):
        role_id = kwargs['role_id']
        response = http_get('platform/api/roles/%s/siblings' % role_id, self.query)
        return self.assert_response_success_data(response)
